//function test(elem1,elem2){
	/*var repeat="test('"+elem1+"','"+elem2+"')";
	alert(repeat);
	movement=setTimeout(repeat,10);
}*/
//--Tone function test(){
	/*var elem=10/10;
	alert(Math.ceil(elem));
	alert(Math.floor(elem));
	alert(Math.round(elem));*/
	/*--Tone if(!document.getElementById)
		return false;
	if(!document.getElementById(elementID))
		return false;
	var elem=document.getElementById(elementID);
	if(elem.movement)
		clearTimeout(elem.movement);
	var posx=parseInt(elem.style.left);
	var posy=parseInt(elem.style.top);
	var dist=0;
	if(posx==final_x&&posy==final_y)
		return true;
	if(posx<final_x){
		dist=Math.ceil((fina_x-posx)/10);
		posx=posx+dist;
	}
	if(posx>final_x){
		dist=Math.ceil((posx-final_x)/10);
		posx=posx-dist;
	}
	if(posy<final_y){
		dist=Math.ceil((final_y-posy)/10);
		posy=posy+dist;
	}
	if(posy>final_y){
		dist=Math.ceil((posy-final_y)/10);
		posy=posy-dist;
	}
	elem.style.left=posx+"px";
	elem.style.top=posy+"px";
	var repeat="moveMessage('"+elementID+"','"+final_x+"','"+final_y+"','"+interval+"')";
	elem.movement=setTimeout(repeat,interval);
}--Tone*/
function test(){//JS中区分大小写
	/*if(!document.getElementById("line"))
		return false;
	var line=document.getElementById("line");
	var image=document.createElement("img");
	image.setAttribute("src","./pic/432-240.jpg");
	image.setAttribute("id","image");
	line.appendChild(image);*/
	var sam;
	//alert(sam);
	//alert(typeof test);
	var car=null;
	//alert(typeof car);
	//alert(null==undefined);
	var message="hi";
	//alert(Boolean(message));
	/*var a=2.1;
	var b=0.2;
	alert(a+b);*/
	//alert(0/0);
	//alert(-1/0);
	/*alert(parseInt("blue"));
	alert(parseInt("123sss"));
	alert(parseInt("AF",16));*/
	/*var num1=parseInt("10",2);
	var num2=parseInt("10",8);
	var num3=parseInt("10",10);
	var num4=parseInt("10",16);
	alert(num1);alert(num2);alert(num3);alert(num4);*/
	/*var num=10;
	alert(num.toString());
	alert(num.toString(2));*/
	/*var value1=10;
	var value2=true;
	var value3=null;
	var value4;
	alert(String(value1));
	alert(String(value2));
	alert(String(value3));
	alert(String(value4));*/
	/*var firstOb=false;
	var secondOb=2;
	alert(firstOb||secondOb);
	alert(firstOb&&secondOb);*/
	/*var a="1";
	var b=2;
	alert(Number(a));
	alert(a*b);*/
	//alert((5-""));alert((5-"11"));
	/*alert(1=="c");
	alert(1==="1");
	alert(null==undefined);
	alert(null===undefined);*/
	/*var res=(1>"cc")?1:"cc";
	alert(res);*/
	/*for(var propName in window){
		document.writeln(propName);
	}*/
	/*var num=0;
	for(var a=0;a<10;a++){
		outerspace:
		for(var b=0;b<10;b++){
			if(a==5&&b==5){
				break outerspace;
			}else{
				num++;
			}
		}
	}
	alert(num);*/
	/*with(location){
		var qs=search.substring(1);
		var hostname=hostname;
		var url=href;
		alert(qs);alert(hostname);alert(rul);
	}*/
	/*switch("hello world"){
		case "hello"+" world":
			alert("Greeting is found");
			break;
		case "goodbye":
			alert("Closing is found");
			break;
		default:
			alert("Unexcepted message is found");
	}
	var num=25;
	switch(true){
		case num<0:
			alert("Less than 0");
			break;
		case num>=0&&num<=10:
			alert("Betweem 0 and 10");
			break;
		case num>10&&num<=20:
			alert("Between 10 and 20");
			break;
		default:
			alert("More than 20");
	}*/
	/*alert(arguments.length);
	alert("hello "+arguments[0]+","+arguments[1]);*/
}
function Test(num1,num2){
	//message="hi";
	//alert("c2");
	"use strict";
	arguments[1]=20;
	alert(num1+num2);
}
function sample(){//延长作用域
	var qs="?debug=true";
	with(location){
		var url=href+qs;
	}
	alert(url);
}
function field(){//无块级作用域
	if(true){
		var color="blue";
	}
	alert(color);
	for(var i=0;i<10;i++){
		color+=i;
	}
	alert(color);
}
var Color="white";
function getColor(){
	//var Color="black";
	return Color;
}
var colors=new Array("red","black","white");
colors[3]="gray";
//alert(colors.length);
//alert(getColor());
//Test(10,10);
//test("you","me");
//addLoadEvent(test);
//sample();
//field();
var person1={
	toLocalString:function(){
		return "c1";
	},
	toString:function(){
		return "c2";
	}
};
var person2={
	toLocalString:function(){
		return "h1";
	},
	toString:function(){
		return "h2";
	}
};
var people=new Array(person1,person2);
//alert(people);
//alert(people.toString());
//alert(people.toLocaleString());
/*var colors=new Array();
var count=colors.push("red","black");
alert(count);

count=colors.push("green");
alert(count);

var item=colors.pop();
alert(item);
alert(colors);*/

/*var colors=new Array();
var count=colors.unshift("black","white");
//alert(count);

count=colors.unshift("green");
//alert(count);

alert(colors.shift());*/
//var values=[5,1,8,3,2];
//function compare(value1,value2){
	/*if(value1<value2){
		return -1;
	}else if(value1>value2){
		return 1;
	}else{
		return 0;
	}*/
	//return value1-value2;
//}
//alert(values.sort(compare));*/

var colors1=["red","green","blue"];
var colors2=colors1.concat("yellow",["blcak","white"]);

//alert(colors1.slice(1));
//alert(colors2.slice(1,colors2.length));

/*colors1.splice(0,1);
colors2.splice(1,0,"black");//从位置1向前插

alert(colors1);
alert(colors2);*/

//alert(colors1.indexOf("green"));
//alert(colors1.lastIndexOf("blue"));

var values=[1,2,3,4,5,6,7,8,9];
//alert(values.indexOf(1));
//alert(values.lastIndexOf(7));
var result1=values.filter(function(item,index,array){
	return (item>2);
});
values.forEach(function(item,index,array){
		values[index]=item+1;
});
var numbers=[1,2,3,4,5];
var sum=numbers.reduce(function(a,b,index,array){
	return a+b;
});
//alert(sum);
var start=new Date(2017,0,17);
var end=Date.now();
//alert(start.toDateString());
var re=null,i;
/*for(i=0;i<10;i++){
	re=new RegExp("cat","g");
	alert(re.test("catastrophe"));
}*/
/*function createComparsionFunction(propertyName){
	return function(object1,object2){
		var value1=object1[propertyName];
		var value2=object2[propertyName];
		if(value1<value2){
			return -1;
		}else if(value1>value2){
			return 1;
		}else{
			return 0;
		}
	};
}
var date=[{"name":"zhangsan","age":25},{"name":"lisi","age":20}];
date.sort(createComparsionFunction("name"));
alert(date[0].name);
date.sort(createComparsionFunction("age"));
alert(date[0].name);*/
/*function callSomeFunction(someFunction,someArgument){
	return someFunction(someArgument);
}
function add10(num){
	return num+10;
}
alert(callSomeFunction(add10,20));*/
/*window.color="black";
function sayColor(){
	alert(this.color);
}
sayColor();
var o={color:"white"};
o.changeColor=sayColor;
o.changeColor();*/
/*function outer(){
	inner();
}
function inner(){
	alert(inner.caller);
}
outer();*/
/*var text="catbatzat";
var result=text.replace(/(.)at/g,"word ($1)");
alert(result);*/
//alert(String.fromCharCode(65,97));
/*function selectItem(lowerValue,upperValue){
	var choices=upperValue-lowerValue+1;
	return Math.floor((Math.random()*choices)+lowerValue);
}
var colors=["black","white","grey"];
alert(colors[selectItem(0,colors.length-1)]);*/
/*var text="cc";
text=text+"1";
alert(text);*/
/*var person={
	_name:"cc",
	age:20,
	job:"software engineer",
	
	sayhello:function(){
		alert(this._name+";"+age);
	}
};
Object.defineProperty(person,"name",{
	get:function(){
		return this.age+1;
	},
	set:function(){
		this.age=21;
	}
});
alert(person.name);*/
/*var book={
};
Object.defineProperties(book,{
	_year:{
		value:2004
	},
	edition:{
		value:-1
	}
});
var des=Object.getOwnPropertyDescriptor(book,"_year");
alert(des.configurable);*/
/*function Person(){
}
Person.prototype.name="cc";
Person.prototype.sayhello=function(){
	alert(this.name);
};
var p1=new Person();
var p2=new Person();
p1.sayhello();p2.sayhello();*/
/*function ex1(){
	this.name="EX1";
}
ex1.prototype={
	constructor:ex2,
	sayName1:function(){
		alert(this.name+"1");
	}
};
function ex2(){
	this.name="EX2";
}
ex2.prototype={
	constructor:ex2,
	sayname2:function(){
		alert(this.name+"2");
	}
};
var e1=new ex1();
var e2=new ex2();
e2.sayname2();*/
/*function createComparsionFunction(propertyName){
	return function(obj1,obj2){
		var value1=obj1[propertyName];
		var value2=obj2[propertyName];
		if(value1<value2){
				return -1;
		}else if(value1>value2){
			return 1;
		}else{
			return 0;
		}
	};
}
var compareNames=createComparsionFunction("name");
alert(compareNames({name:"zhangsan"},{name:"lisi"}));
compareNames=null;*/
/*function createFunctions(){
	var result=new Array();
	for(var i=0;i<10;i++){
		result[i]=function(){
			return i;
		};
	}
	return result;
}
alert(createFunctions());*/
/*function createFunctions(){
	var result=new Array();
	for(var i=0;i<10;i++){
		result[i]=function(num){
			return function(){
				return num;
			};
		}(i);
	}
	return result;
}
alert(createFunctions());*/
/*function createFunctions(){
	var result=new Array();
	
	for(var i=0;i<10;i++){
		result[i]=function(){
			return i;
		}();
	}
	return result;
}
var res=createFunctions();
alert(res);*/
function dos(interval){
	alert("cc");
	var msg="dos('"+interval+"')";
	setTimeout(msg,interval);
}
//dos(1000);
/*setInterval(function(){
	alert("cc")
},1000);*/
/*var num=0;
var max=10;
var intervalid=null;

function incrementNumber(){
	num++;
	if(num==max){
		clearInterval(intervalid);
		alert("done");
	}
}
intervalid=setInterval(incrementNumber,1000);*/
/*var result=prompt("what is your name?","");
if(result==null||result.length==0){
	alert("empty");
}*/
//var html=document.documentElement;
//alert(document.childNodes[0]);
//document.title="testcc";
//alert(document.getElementsByTagName("*").length);

//alert(document.getElementsByName("color").length);
/*var count=0;
var res;
function outputTime(interval){
	document.write("<p>"+"<strong>"+new Date().toString()+"</strong>"+"</p>");
	count++;
	if(count==3){
		clearTimeout(res);
	}else{
		res=setTimeout("outputTime('"+interval+"')",interval);
		//clearTimeout(res);
	}
}
window.onload=outputTime(1000);*/
/*var div=document.getElementById("line");
div.setAttribute("ID","line1");
div.CD="line2";
alert(div.id+";"+div.getAttribute("CD"));*/
/*var div=document.getElementById("line");
var id=div.attributes["name"].nodeValue;
alert(id);*/

/*var div=document.getElementById("line");
function outputAttributes(element){
	var arr=new Array(),nodeName,nodeValue,i,len;
	for(i=0;i<div.attributes.length;i++){
		nodeName=div.attributes[i].nodeName;
		nodeValue=div.attributes[i].nodeValue;
		arr.push(nodeName+"=\""+nodeValue+"\"");
	}
	alert(arr.join(";"));
}
outputAttributes(div);*/
/*var list=document.getElementById("lione");
list.childNodes[0].nodeValue="cc cc";*/
/*var element=document.createElement("div");
var textNode=document.createTextNode("hello");
element.appendChild(textNode);
document.body.appendChild(element);*/
//alert("hi");
/*var div=document.getElementById("line");
div.classList.remove("user");
var classNames=div.className.split(/\s+/);
div.className=classNames.join(" ");
alert(div.className);*/
//var div=document.getElementById("mylist");
//div.outerHTML="<p>this is a paragraph.</p>";
//alert(document.documentElement.contains(document.body));
//alert(div.innerText);
//div.outerText="hello";
//alert(!document.getElementById("mylist"));
//document.body.scrollByLines(20);
//var table=document.getElementById("mytable");
//table.style.border="10px solid red";
//alert(div.style.cssText);
/*for(var i=0,len=div.style.length;i<len;i++){
	alert(div.style[i]);
}*/
//div.style.removeProperty("border");
/*var computedStyle=document.defaultView.getComputedStyle(div,null);
alert(computedStyle.backgroundColor);
alert(computedStyle.height);*/
/*function showMes(value){
	alert(value);
}*/
/*btn.addEventListener("click",function(){
	alert(this.id);
},false);
btn.addEventListener("click",function(){
	alert("hello");
},false);*/
var btn=document.getElementById("btn2");
var handler=function(){
	alert("hello");
};
alert("cc");
/*
btn.attachEvent("onclick",function(){
	alert("hello");
});*/
//btn.addEventListener("click",handler,false);
//btn.removeEventListener("click",handler,false);
//btn.onclick=showMes("hello"); 很好的错误实例
var EventUtil={
	addHandler:function(element,type,handler){
		if(element.addEventListener){
			element.addEventListener(type,handler,false);
		}else if(element.attachEvent){
			element.attachEvent("on"+type,handler);
		}else{
			element.["on"+type]=handler;
		}
	},
	removeHandler:function(element,type,handler){
		if(element.removeEventListener){
			element.removeEventListener(type,handler,false);
		}else if(element.detachEvent){
			element.detachEvent("on"+type,handler);
		}else{
			element.["on"+type]=null;
		}
	}
};
EventUtil.addHandler(btn,"click",handler);





